package main

import "fmt"

func main() {
	var s = []int{1, 2, 3}

	fmt.Printf("%p\n", &s)
	s = append(s, 4)
	fmt.Printf("%p\n", &s)

	// 向开头插入值或者切片
	var a = []int{1, 2, 3}
	fmt.Println(append([]int{0}, a...))

	// 任意位置插值
	var b = []int{1, 2, 3, 4, 5}
	var i = 2
	fmt.Println(append(b[:i], append([]int{100}, b[i:]...)...))

	// 删除元素
	// 从切片中删除元素
	d := []int{30, 31, 32, 33, 34, 35, 36, 37}
	// 要删除索引为2的元素
	e := append(d[:2], d[3:]...)
	fmt.Println(e) //[30 31 33 34 35 36 37]
}
